<?php
    require_once "config.php";
    if($_SERVER['REQUEST_METHOD'] == 'POST'){
        $params = array(
            'fans_id'   => $_POST['fans_id'],
            'fans_name'   => $_POST['fans_name'],
            'fans_avatar'   => $_POST['fans_avatar'],
            'u_id'   => $_POST['u_id'],
            'u_name'   => $_POST['u_name'],
            'u_avatar'   => $_POST['u_avatar'],
            'time'   => time(),
        );
        $sql = $mysql->query("select * from dyspw_follow where fans_id = {$params['fans_id']} and u_id = {$params['u_id']}");
        $rows = $sql->fetch_all(MYSQLI_ASSOC);
        if(!empty($rows)){
            $result['status'] = 'n';
            $result['info'] = '您已关注此用户';
            exit(json_encode($result));
        }

        $follow_ins = $mysql->query("insert into dyspw_follow (fans_id,fans_name,fans_avatar,u_id,u_name,u_avatar,time) values ('{$params['fans_id']}','{$params['fans_name']}','{$params['fans_avatar']}','{$params['u_id']}','{$params['u_name']}','{$params['u_avatar']}','{$params['time']}')");
        if($follow_ins){
            $result['status'] = 'y';
            $result['info'] = '关注成功';
            exit(json_encode($result));
        }
    }
 ?>
